package com.zimin.cloud.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zimin.cloud.mine.pojo.system.business.PostBO;
import com.zimin.cloud.mine.pojo.system.business.RoleBO;
import com.zimin.cloud.system.pojo.entity.Post;
import com.zimin.cloud.system.mapper.PostMapper;
import com.zimin.cloud.system.pojo.entity.Role;
import com.zimin.cloud.system.service.IPostService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zimin.common.utils.ObjectUtils;
import com.zimin.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.sql.Array;
import java.util.List;

/**
 * <p>
 * 岗位信息 服务实现类
 * </p>
 *
 * @author zimin
 * @since 2021-12-30 11:05
 */
@Service("postService")
@Slf4j
public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements IPostService {

    /**
     * <p>查询wrappers</p>
     *
     * @param postBO 岗位
     * @return com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.zimin.cloud.system.pojo.entity.Post>
     * @since 2022-02-19 17:12:37
     */
    public LambdaQueryWrapper<Post> queryWrappers(PostBO postBO) {
        if (ObjectUtils.isEmpty(postBO)) {
            return null;
        }
        return Wrappers.<Post>lambdaQuery()
                .like(StringUtils.isNotBlank(postBO.getPostName()), Post::getPostName, postBO.getPostName())
                .eq(ObjectUtils.isNotEmpty(postBO.getStatus()), Post::getStatus, postBO.getStatus())
                .eq(ObjectUtils.isNotEmpty(postBO.getPostCode()), Post::getPostCode, postBO.getPostCode())
                .orderByDesc(List.of(Post::getSort, Post::getCreateTime));

    }
}
